#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define	MAX_NUMBER		1000000

struct t_pair
{
	unsigned int k;
	unsigned int v;
};
typedef struct t_pair pair;

int cmp(const void*a, const void*b)
{
	return ((pair*)a)->k-((pair*)b)->k;
}

int main()
{
	pair *tab;
	unsigned int N,i,v,k;
	
	tab=malloc(sizeof(pair)*MAX_NUMBER);
	memset(tab,0,sizeof(pair)*MAX_NUMBER);
	scanf("%u",&N);	
	for(i=0;i<N;i++)
	{
		scanf("%u %u",&tab[i].k,&tab[i].v);
	}
	qsort(tab,MAX_NUMBER,sizeof(pair),cmp);
	for(i=0;i<N;i++)
	{
		printf("%u %u\n",tab[i].k,tab[i].v);
	}	
	return 0;	
}
